1027E - Inverse Coloring - CodeForces Solution


combinatorics dp math *2100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
const int N=505;
int dis[N],dis2[N],mid=998244353; 
signed main(){
	int n=read(),k2=read();
	int sum=0;
	for(int i=1;i<=n;++i){
		dis[0]=1;
		for(int j=1;j<=n;++j){
			dis[j]=0;
			for(int k=1;k<=min(i,j);++k){
				dis[j]=dis[j]+dis[j-k];
				dis[j]%=mid; 
			}
		}
		dis2[i]=(dis[n]%mid-sum%mid+mid)%mid;
		sum=dis[n]%mid;
	}
	int ans=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i*j<k2){
				ans=ans+dis2[i]*dis2[j]%mid;
				ans%=mid;
			}
		}
	}
	ans*=2;
	ans%=mid;
	printf("%lld\n",ans%mid);
	return 0;
}


Comments

Submit
0 Comments
More Questions

Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses